#include <stdio.h>
#include <string.h>

char month1[19][10]={"pop","no","zip","zotz","tzec",
				 "xul", "yoxkin", "mol", "chen", "yax",
				 "zac", "ceh", "mac", "kankin", "muan", 
				 "pax", "koyab", "cumhu","uayet"};
char month2[21][10]={"error","imix","ik","akbal","kan","chicchan",
				 "cimi","manik","lamat","muluk","ok",
				 "chuen","eb","ben","ix","mem",
				 "cib","caban","eznab","canac","ahau"};
int yy,mm,dd,tot;
char ss[10];
char ch;
main()
{
	int n, i, j;

	scanf("%d", &n);
	printf("%d\n", n);
	while (n-->0)
	{
		scanf("%d%c%s%d", &dd, &ch, ss, &yy);
//		printf("read=%d %s %d\n", dd,ss,yy);
		for (i=0; i<19; ++i)
			if (strcmp(ss,month1[i])==0) break;
		tot=365*yy+i*20+dd+1;
		yy=(tot-1)/260;
		tot%=260;
		if (tot==0) tot=260;
		mm=tot%20;
		dd=tot%13;
		if (mm==0) mm=20;
		if (dd==0) dd=13;
		printf("%d %s %d\n", dd, month2[mm], yy);


	}


	return 0;
}
// start at 20:00